import request from '@/utils/useRequest'
import axios from "axios";
export const httpUpload = (file) => {
    let formData = new FormData()
    formData.append('file', file)
    return request({
        url: '/upload/file',
        method: 'post',
        data: formData
    })
}
export const http = {
    login: (data) => {
        return request({
            url: '/user/login',
            data,
            method: 'post'
        })
    },
    logout: (data) => {
        return request({
            url: '/user/logout',
            data,
            method: 'post'
        })
    },
    question: {
        page: (data) => {
            return request({
                url: '/question',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/question/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/question/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/question',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/question/' + id,
                method: 'delete'
            })
        },
        read: (id) => {
            return request({
                url: '/question/' + id,
                method: 'get'
            })
        },
    },
    questionOption: {
        page: (data) => {
            return request({
                url: '/questionOption',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/questionOption/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/questionOption/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/questionOption',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/questionOption/' + id,
                method: 'delete'
            })
        },
        read: (id) => {
            return request({
                url: '/questionOption/' + id,
                method: 'get'
            })
        },
    },
    answer: {
        page: (data) => {
            return request({
                url: '/answer',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/answer/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/answer/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/answer',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/answer/' + id,
                method: 'delete'
            })
        },
        read: (id) => {
            return request({
                url: '/answer/' + id,
                method: 'get'
            })
        },
    },
    news: {
        page: (data) => {
            return request({
                url: '/news',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/news/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/news/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/news',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/news/' + id,
                method: 'delete'
            })
        },
        read: (id) => {
            return request({
                url: '/news/' + id,
                method: 'get'
            })
        },
    },
    notice: {
        page: (data) => {
            return request({
                url: '/notice',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/notice/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/notice/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/notice',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/notice/' + id,
                method: 'delete'
            })
        },
        read: (id) => {
            return request({
                url: '/notice/' + id,
                method: 'get'
            })
        },
    },
    banner: {
        page: (data) => {
            return request({
                url: '/banner',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/banner/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/banner/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/banner',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/banner/' + id,
                method: 'delete'
            })
        },
        read: (id) => {
            return request({
                url: '/banner/' + id,
                method: 'get'
            })
        },
    },
    role: {
        page: (data) => {
            return request({
                url: '/role',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/role/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/role/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/role',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        del: (id) => {
            return request({
                url: '/role/' + id,
                method: 'delete'
            })
        },
        read: (id) => {
            return request({
                url: '/role/' + id,
                method: 'get'
            })
        },
    },
    user: {
        page: (data) => {
            return request({
                url: '/user',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/user/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/user/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/user',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        read: (id) => {
            return request({
                url: '/user/' + id,
                method: 'get'
            })
        },
        del: (id) => {
            return request({
                url: '/user/' + id,
                method: 'delete'
            })
        }
    },
    post: {
        page: (data) => {
            return request({
                url: '/post',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/post/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/post/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/post',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        read: (id) => {
            return request({
                url: '/post/' + id,
                method: 'get'
            })
        },
        del: (id) => {
            return request({
                url: '/post/' + id,
                method: 'delete'
            })
        }
    },
    comment: {
        page: (data) => {
            return request({
                url: '/comment',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/comment/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/comment/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/comment',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        read: (id) => {
            return request({
                url: '/comment/' + id,
                method: 'get'
            })
        },
        del: (id) => {
            return request({
                url: '/comment/' + id,
                method: 'delete'
            })
        }
    },
    collect: {
        page: (data) => {
            return request({
                url: '/collect',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/collect/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/collect/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/collect',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        read: (id) => {
            return request({
                url: '/collect/' + id,
                method: 'get'
            })
        },
        del: (id) => {
            return request({
                url: '/collect/' + id,
                method: 'delete'
            })
        }
    },
    like: {
        page: (data) => {
            return request({
                url: '/like',
                params: data,
                method: 'get'
            })
        },
        list: (data) => {
            return request({
                url: '/like/list',
                params: data,
                method: 'get'
            })
        },
        update: (data) => {
            return request({
                url: '/like/' + data.id,
                data: {
                    ...data,
                    id: undefined
                },
                method: 'put'
            })
        },
        create: (data) => {
            return request({
                url: '/like',
                data: {
                    ...data,
                },
                method: 'post'
            })
        },
        read: (id) => {
            return request({
                url: '/like/' + id,
                method: 'get'
            })
        },
        del: (id) => {
            return request({
                url: '/like/' + id,
                method: 'delete'
            })
        }
    },
}